/* This file is part of MyRename
 * Copyright (C) 2005-2009 Kai-Chieh Ku (kjackie@gmail.com)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#pragma once

#define DRIVELEN ((26 << 2) + 1)

// CDirTreeCtrl

class CDirTreeCtrl : public CTreeCtrl
{
	DECLARE_DYNAMIC(CDirTreeCtrl)

public:
	CDirTreeCtrl();
	virtual ~CDirTreeCtrl();
	void Init();
	void Localize();
	void InsertChildren(HTREEITEM parent, bool fast = false);
	void DeleteChildren(HTREEITEM parent);
	void GetFullPath(HTREEITEM item, CString &path);
	void SetSelectPath(CString strPath);
	HTREEITEM SelectPath(LPCTSTR path);
	HTREEITEM ExpandPath(LPCTSTR path);
	HTREEITEM FindSiblingItem(HTREEITEM from, LPCTSTR text);
	HTREEITEM SelectChildItem(LPCTSTR text);
	afx_msg void OnTvnSelectChanged(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnTvnItemExpanding(NMHDR *pNMHDR, LRESULT *pResult);
private:
	void UpdateMenu();
	CImageList m_treeImg;
	CString m_sEditName;
	HTREEITEM m_hEditItem;
	CMenu m_context;
	TCHAR m_drive_str[DRIVELEN];
	DECLARE_MESSAGE_MAP()
public:
	void OnEditCopy();
	void OnEditUndo();
	afx_msg void OnSetFocus(CWnd* pOldWnd);
	afx_msg void OnNMRclick(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/);
	afx_msg void OnKillFocus(CWnd* pNewWnd);
	afx_msg void OnTvnEndlabeledit(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnTvnBeginlabeledit(NMHDR *pNMHDR, LRESULT *pResult);
protected:
	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
	virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
};
